package com.rqf.scheduler;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.rqf.ls.service.IVerifyOfLawyerService;
import com.rqf.ls.service.IVerifyService;

@Component
public class VerifyCleanInvoker {
	
	private ExecutorService threadPool = null;
	@Autowired
	private IVerifyService verifyService;
	@Autowired
	private IVerifyOfLawyerService lsVerifyService;

	
	public VerifyCleanInvoker(){
		threadPool = Executors.newCachedThreadPool(new ThreadFactory() {
			@Override
			public Thread newThread(Runnable r) {
				Thread thread = new Thread(r);
				thread.setDaemon(true);
				return thread;
			}
		});
	}
	
	@Scheduled(cron = "0 0/5 * * * ?")  
	public void refreshwfMenuData() throws InterruptedException{
            threadPool.execute(new Runnable(){
                @Override 
                public void run() { 
                	verifyService.clean();
                	lsVerifyService.clean();
                } 
            });            
	}
}
